<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active {
            color: red;
        }
    </style>
</head>
<body>

<!--v-cloak是斗篷的意思，加载完app再显示文本-->
<div id="app">
    <h2>总价格： {{totalPrice}}</h2>
</div>


<script src="../js/vue.js"></script>
<script>

    const app = new Vue({
            el: '#app',
            data: {
                msg: 'hello',
                firstName: 'java',
                lastName: 'vue',
                books:[
                    {id: 110, name: 'linux编程', price: 119},
                    {id: 112, name: 'windows编程', price: 120},
                    {id: 113, name: 'java编程', price: 115},
                    {id: 114, name: 'vue编程', price: 116}
                ]
            },
            computed: {
                fullName: function () {
                    return this.firstName + ' ' + this.lastName
                },
                totalPrice:  function () {
                    let result = 0
                    for (let i=0; i < this.books.length; i++){
                        result += this.books[i].price
                    }
                    return result
                }
            }
      })

</script>

</body>
</html>